import servlet.AddServlet;
import servlet.FindAllServlet;
import servlet.LoginServlet;
import org.apache.catalina.Context;
import org.apache.catalina.LifecycleException;
import org.apache.catalina.Wrapper;
import org.apache.catalina.startup.Tomcat;

public class Main {
    public Main() {
        Tomcat tomcat = new Tomcat();
        tomcat.setPort(8099);
        tomcat.getConnector();

        Context context = tomcat.addContext("", null);

        Wrapper wp = Tomcat.addServlet(context, "test", new LoginServlet());
        wp.setLoadOnStartup(1);
        wp.addMapping("/abc");

        Wrapper wp1 = Tomcat.addServlet(context, "add", new AddServlet());
        wp1.setLoadOnStartup(2);
        wp1.addMapping("/add");

        Wrapper wp2 = Tomcat.addServlet(context, "findAll", new FindAllServlet());
        wp2.setLoadOnStartup(2);
        wp2.addMapping("/findAll");

        try {
            tomcat.start();
        } catch (LifecycleException e) {
            e.printStackTrace();
        }
    }

    public static void main(String[] args) {
        new Main();
//        IUserDao dao=new UserDaoImp();
//        System.out.println(dao.findByGrad("吴安序","666666"));
    }
}
